import request from '@/utils/request'

export function getDepts(params) {
  return request({
    url: '/web-api/api/dept',
    method: 'get',
    params
  })
}

export function getDeptSuperior(ids) {
  const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
  return request({
    url: '/web-api/api/dept/superior',
    method: 'post',
    data
  })
}

export function add(data) {
  return request({
    url: '/web-api/api/dept',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: '/web-api/api/dept',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: '/web-api/api/dept',
    method: 'put',
    data
  })
}

export function getList(params) {
  return request({
    url: '/web-api/api/dept/list',
    method: 'get',
    params
  })
}

export function roleDeptTreeselect(roleId) {
  return request({
    url: '/web-api/system/dept/roleDeptTreeselect/' + roleId,
    method: 'get',
  })
}

export function getTreeselect(params) {
  return request({
    url: '/web-api/system/dept/treeselect/sub',
    method: 'get',
    params: params
  })
}


export function addDeptCategory(data) {
  return request({
    url: '/web-api/system/dept-category',
    method: 'post',
    data
  })
}

export function listDeptCategory(params) {
  return request({
    url: '/web-api/patrol/unit/dept/list',
    method: 'get',
    params: params
  })
}

export function delDeptCategory(params) {
  return request({
    url: '/web-api/system/dept-category/' + params,
    method: 'delete'
  })
}

// 巡检对象

export function getSupervise(params) {
  return request({
    url: '/web-api/supervise/info/list',
    method: 'get',
    params: params
  })
}

export function addSupervise(data) {
  return request({
    url: '/web-api/patrol/unit/dept',
    method: 'post',
    data
  })
}

export function delSupervise(data) {
  return request({
    url: `/web-api/patrol/unit/dept/delete/${data}`,
    method: 'get',
  })
}

// 执法人员

export function getPatrolUser(params) {
  return request({
    url: '/web-api/patrol/user/list',
    method: 'get',
    params: params
  })
}

export function getUserList(params) {
  return request({
    url: '/web-api/system/user/list',
    method: 'get',
    params: params
  })
}

// 查询随机检查对象
export function queryRandomObj(params) {
  return request({
    url: '/web-api/patrol/task/plan/random/unit',
    method: 'get',
    params: params
  })
}

// 查询随机执法人员
export function queryRandomUser(params) {
  return request({
    url: '/web-api/patrol/task/plan/random/user',
    method: 'get',
    params: params
  })
}


export function addPatrolUser(data) {
  return request({
    url: '/web-api/patrol/user',
    method: 'post',
    data
  })
}

export function delPatrolUser(data) {
  return request({
    url: `/web-api/patrol/user/delete/${data}`,
    method: 'get',
  })
}


export default { add, edit, del, getDepts, getDeptSuperior }
